﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using EventMgrLib;
using SmartMotion.Core;
using Sunny.UI;
using WeifenLuo.WinFormsUI.Docking;

namespace SmartMotion.AllPages.DockPanels
{
    public partial class FrmParms : DockContent
    {
        public FrmParms()
        {
            InitializeComponent();
            HideOnClose = true;
        }

        private void FrmParms_Load(object sender, EventArgs e)
        {
            EventMgr.Ins .GetEvent<SelectActionChanged>().Subscribe(SelectedItemChanged);
        }

        private void SelectedItemChanged(ActionItem item)
        {
            if (item == null) return;
            Controls.Clear();
            if (item.GetParmsPage() is UIPage frm)
            {
                Controls.Add(frm);
                frm.Dock = DockStyle.Fill;
                frm.Show();
            }
        }
    }
}
